//
// Created by hjie on 23-9-17.
//

#include "heart_beat_module.h"
#include "message_router.h"
#include "logic_room_data.h"
#include "./../protocol/msg_key.h"
#include "./../protocol/heart_beat_protocol.h"

HeartBeatModule::HeartBeatModule(const std::string & module_name)
{
    m_module_name = module_name;
}

void HeartBeatModule::RegisterMsg(MessageRouter *router)
{
    REGISTER_MSG_TYPE(heart_beat_k, HeartBeatModule, HeartBeat, this);

    m_msg_type_set.insert(heart_beat_k);
}

std::shared_ptr<BaseProtocol> HeartBeatModule::CreateProtocolData(const std::string &msg, rapidjson::Document &input)
{
    if (msg == heart_beat_k)
    {
        return std::shared_ptr<BaseProtocol>(new HeartBeatProtocol);
    }
    return nullptr;
}

void HeartBeatModule::HeartBeat(RoomReferenceData *data, std::shared_ptr<BaseProtocol> &request)
{
    data->m_connection_data->UpdateTime();
}